package com.gitee.wsl.ext.map


/**
 * @param src1
 * Original map.
 * @param src2
 * Additional map.
 * @param <K>
 * Key type.
 * @param <V>
 * Value type.
 *
 * @return New map containing only the entries *(by keys)* not shared by the two maps.
</V></K> */

fun <K, V> distinct(src1: Map<K,V>?, src2: Map<K,V>?): Map<K, V> {
    val map1: Map<K,V>?
    val map2: Map<K,V>?

    if (src1 != null) {
        map1 = HashMap(src1)
        if (src2 != null) for (key in src2.keys) map1.remove(key)
    } else {
        map1 = null
    }

    if (src2 != null) {
        map2 = HashMap(src2)
        if (src1 != null) for (key in src1.keys) map2.remove(key)
    } else {
        map2 = null
    }

    return combine(map1, map2)
}